package com.saihai.jiankang.userXs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.saihai.jiankang.userXs.domain.JkUserXs;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.saihai.common.annotation.Log;
import com.saihai.common.core.controller.BaseController;
import com.saihai.common.core.domain.AjaxResult;
import com.saihai.common.enums.BusinessType;
import com.saihai.jiankang.userXs.service.IJkUserXsService;
import com.saihai.common.utils.poi.ExcelUtil;
import com.saihai.common.core.page.TableDataInfo;

/**
 * 家长学生关联Controller
 * 
 * @author ruoyi
 * @date 2024-06-28
 */
@RestController
@RequestMapping("/jiankang/userXs")
public class JkUserXsController extends BaseController
{
    @Autowired
    private IJkUserXsService jkUserXsService;

    /**
     * 查询家长学生关联列表
     */
    @GetMapping("/list")
    public TableDataInfo list(JkUserXs jkUserXs)
    {
        startPage();
        List<JkUserXs> list = jkUserXsService.selectJkUserXsList(jkUserXs);
        return getDataTable(list);
    }





    /**
     * 导出家长学生关联列表
     */
    @PreAuthorize("@ss.hasPermi('userXs:userXs:export')")
    @Log(title = "家长学生关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JkUserXs jkUserXs)
    {
        List<JkUserXs> list = jkUserXsService.selectJkUserXsList(jkUserXs);
        ExcelUtil<JkUserXs> util = new ExcelUtil<JkUserXs>(JkUserXs.class);
        util.exportExcel(response, list, "家长学生关联数据");
    }

    /**
     * 获取家长学生关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('userXs:userXs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jkUserXsService.selectJkUserXsById(id));
    }

    /**
     * 新增家长学生关联
     */
    @PreAuthorize("@ss.hasPermi('userXs:userXs:add')")
    @Log(title = "家长学生关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JkUserXs jkUserXs)
    {
        return toAjax(jkUserXsService.insertJkUserXs(jkUserXs));
    }

    /**
     * 修改家长学生关联
     */
    @PreAuthorize("@ss.hasPermi('userXs:userXs:edit')")
    @Log(title = "家长学生关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JkUserXs jkUserXs)
    {
        return toAjax(jkUserXsService.updateJkUserXs(jkUserXs));
    }

    /**
     * 删除家长学生关联
     */
    @PreAuthorize("@ss.hasPermi('userXs:userXs:remove')")
    @Log(title = "家长学生关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jkUserXsService.deleteJkUserXsByIds(ids));
    }

    /**
     * 解绑学生
     */
    @Log(title = "解绑学生", businessType = BusinessType.DELETE)
    @DeleteMapping("/unbindStudent/{id}")
    public AjaxResult unbindStudent(@PathVariable Long id)
    {
        return toAjax(jkUserXsService.deleteJkUserXsById(id));
    }
}
